package com.blrs.service.honor.impl;

import java.util.List;

import com.blrs.common.utils.ReflectionUtils;
import com.blrs.common.utils.uuid.UUID;
import com.blrs.mapper.QualificationInfoMapper;
import com.blrs.service.honor.IHonorResumeService;
import com.blrs.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.blrs.mapper.HonorResumeMapper;
import com.blrs.domain.HonorResume;

/**
 * 荣誉资质履历Service业务层处理
 * 
 * @author zhongliang
 * @date 2023-08-28
 */
@Service
public class HonorResumeServiceImpl implements IHonorResumeService
{
    @Autowired
    private HonorResumeMapper honorResumeMapper;
    @Autowired
    private SysUserMapper userMapper;
    @Autowired
    private QualificationInfoMapper qualificationInfoMapper;

    /**
     * 查询荣誉资质履历
     * 
     * @param id 荣誉资质履历主键
     * @return 荣誉资质履历
     */
    @Override
    public HonorResume selectHonorResumeById(String id)
    {

        HonorResume honorResume = honorResumeMapper.selectHonorResumeById(id);
        honorResume.setCreateId(userMapper.selectUserById(Long.valueOf(honorResume.getCreateId())).getUserName());
        String s = qualificationInfoMapper.selectUploadUrl(honorResume.getUploadFile());
        honorResume.setFileUrl(s);

        return honorResume;
    }

    /**
     * 查询荣誉资质履历列表
     * 
     * @param honorResume 荣誉资质履历
     * @return 荣誉资质履历
     */
    @Override
    public List<HonorResume> selectHonorResumeList(HonorResume honorResume)
    {

        List<HonorResume> honorResumes = honorResumeMapper.selectHonorResumeList(honorResume);
        for (HonorResume resume : honorResumes) {
            resume.setCreateId(userMapper.selectUserById(Long.valueOf(resume.getCreateId())).getUserName());
            resume.setFileUrl(qualificationInfoMapper.selectUploadUrl(resume.getUploadFile()));
        }
        return honorResumes;
    }

    /**
     * 新增荣誉资质履历
     * 
     * @param honorResume 荣誉资质履历
     * @return 结果
     */
    @Override
    public int insertHonorResume(HonorResume honorResume)
    {
        honorResume.setId(UUID.randomUUID().toString().replaceAll("-", ""));
        honorResume.setCreateId(String.valueOf(userMapper.selectUserByUserName(honorResume.getCreateId()).getUserId()));
        return honorResumeMapper.insertHonorResume(honorResume);
    }

    /**
     * 修改荣誉资质履历
     * 
     * @param honorResume 荣誉资质履历
     * @return 结果
     */
    @Override
    public int updateHonorResume(HonorResume honorResume)
    {
        return honorResumeMapper.updateHonorResume(honorResume);
    }

    /**
     * 批量删除荣誉资质履历
     * 
     * @param ids 需要删除的荣誉资质履历主键
     * @return 结果
     */
    @Override
    public int deleteHonorResumeByIds(String[] ids)
    {
        return honorResumeMapper.deleteHonorResumeByIds(ids);
    }

    /**
     * 删除荣誉资质履历信息
     * 
     * @param id 荣誉资质履历主键
     * @return 结果
     */
    @Override
    public int deleteHonorResumeById(String id)
    {
        return honorResumeMapper.deleteHonorResumeById(id);
    }
}
